package com.data.unityplugin_market.view

import android.app.Dialog
import android.content.Context
import android.os.Message
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import com.alipay.sdk.app.PayTask
import com.data.unityplugin_market_lib.R
import java.util.logging.Handler

/**
 * Created by LeoLu on 2017/10/26.
 */
public class PaymentDialog(context : Context, style : Int) : Dialog(context , style), View.OnClickListener{


    init {
        init()
    }



    var submit : TextView? = null;

    var cancel : TextView ? = null

    var view : View? = null

    var text : String = ""

    var alipayImage : ImageView ?= null

    var wechatImage : ImageView ? = null

    var unionImage : ImageView ? = null

    fun init(){
        view = layoutInflater.inflate(R.layout.dialog_add_recommend_tag,null)
        alipayImage = view!!.findViewById<ImageView>(R.id.ic_alipay)
        wechatImage = view!!.findViewById<ImageView>(R.id.ic_alipay)
        unionImage = view!!.findViewById<ImageView>(R.id.ic_alipay)
        alipayImage!!.setOnClickListener(this)
        wechatImage!!.setOnClickListener(this)
        unionImage!!.setOnClickListener(this)

    }

    fun setListenerCallBack(lis : PaymentListener) {
        listener = lis
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {

        dismiss()
        return super.onTouchEvent(event)
    }

    override fun onClick(v: View?) {
        when(v!!.id) {
            R.id.ic_alipay -> {
                listener?.onPayClick(PaymentListener.ALIPAY)


            }
            R.id.ic_unionpay -> {
                listener?.onPayClick(PaymentListener.ALIPAY)
            }

            R.id.id_wechat -> {
                listener?.onPayClick(PaymentListener.ALIPAY)
            }

        }
    }

    var listener : PaymentListener ? = null

    open interface PaymentListener{
        companion object {

            val ALIPAY = 1
            val WECAHT_PAY = 2;
            val UNIONPAY = 3;
        }


        fun onPayClick(type: Int)
    }

    override fun show() {
        addContentView(view!!, android.view.ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
        super.show()


    }



}